<template>
    <div class="today-price-container">
        <div class="today-price-box">
            <div class="today-price-box-top">
                <div class="today-price-box-top-left">今日报价</div>
                <ul class="today-price-box-top-right">
                    <!-- <li class="active">全部</li>
                    <li>安格斯牛肉</li>
                    <li>黑木耳</li> -->
                    <li v-for="(item,index) in titleData" :key="index" :class="activeClass == index ? 'active':''" @click="getItem(index)">
						{{item.title}}
					</li>
                </ul>
            </div>
            <ul class="today-price-box-bottom">
                <li class="title">
                    <span>品名</span>
                    <span>市场</span>
                    <span>价格</span>
                    <span>涨幅</span>
                </li>
                <!-- <li class="content">
                    <span>安格斯牛肉</span>
                    <span>华北农贸市场</span>
                    <span class="color-orange">975.62元/kg</span>
                    <span class="color-orange">上升</span>
                </li> -->
                <li class="content" v-for="(item, index) in detail" :key="index">
                    <span>{{item.productName}}</span>
                    <span>{{item.fromSource}}</span>
                    <span class="color-orange">{{item.price}}{{item.currencyUnit}}/{{item.weightUnit}}</span>
                    <span class="color-orange">{{item.rise == 1 ? '涨价' : item.rise == 2 ? '持平' : '下降'}}</span>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    data(){
		return {
            activeClass: 0,
			titleData: [
				// {title: '全部'},
				// {title: '安格斯牛肉'},
				// {title: '黑木耳'}
            ],
            detail: {}
		}
    },
    created() {
        this.getData()
    },
	methods: {
		getItem(index){
			this.activeClass = index;
        },
        getData() {
            this.$api.get('/api/quited_price/today_price?noLoading')
                .then((res) => {
                    this.detail = res.data;
                    this.titleData = [
                        {
                            title: res.data[0].productName
                        }
                    ]
                })
        }
	}
}
</script>

<style lang="scss" scoped>
    .active{
		color: #F9CA25;
	}

    .today-price-container {
        width: 100%;
        padding: 0 16px 14px;
        background-color: #fff;

        .today-price-box {
            width: 100%;
            // min-height: 118px;
            padding: 10px;
            padding-top: 0;
            background-color: #31BC8D;
            box-shadow: 0 2px 12px #888;
            border-radius: 8px;

            .today-price-box-top {
                display: flex;
                justify-content: space-between;
                align-items: center;
                width: 100%;
                padding: 8px 6px;
                box-sizing: border-box;
                color: #fff;
                font-size: 12px;

                .today-price-box-top-left {
                    font-size: 14px;
                }

                .today-price-box-top-right {
                    display: flex;
                    align-items: center;

                    li {
                        margin-left: 16px;

                        &:nth-of-type(1) {
                            margin-left: 0;
                        }
                    }
                }
            }

            .today-price-box-bottom {
                width: 100%;
                padding: 16px 14px;
                padding-bottom: 6px;
                box-sizing: border-box;
                border-radius: 8px;
                background-color: #fff;

                li {
                    display: flex;
                    margin-bottom: 6px;

                    &.title {
                        span {
                            color: #969C9E;
                        }
                    }

                    &.content {
                        span {
                            color: #5D6164;
                        }
                    }

                    span {
                        display: block;
                        font-size: 12px;

                        &:nth-of-type(1) {
                            width: 30%;
                        }
                        &:nth-of-type(2) {
                            width: 33%;
                        }
                        &:nth-of-type(3) {
                            width: 25%;
                            text-align: center;
                        }
                        &:nth-of-type(4) {
                            width: 12%;
                            text-align: center;
                        }
                    }
                }
            }

            .color-orange {
                color: #F58523!important;
            }
        }
    }
</style>